package com.concurrent.controller;


import com.concurrent.SecondKillApplication;
import com.concurrent.service.SeckillService;
import com.concurrent.util.RedisService;
import org.springframework.boot.SpringApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class SeckillController {

    @Resource
    private SeckillService seckillService;
    @Resource
    private RedisService redisService;

    @RequestMapping("/redis/seckill")
    public String secKill(int uid,int skuId){
         return seckillService.seckill(uid,skuId);
    }

    @RequestMapping("/redis/testlua")
    public String testlua(int skuId){
        String secCount = "skuId_count_";
        String bookedName = "skuId_booked_";
        Boolean isSuccess = redisService.getAndIncrLua(bookedName+skuId,secCount+skuId);
        return "isSuccess:"+isSuccess;
    }
    public static void main(String[] args) {
        System.out.println(System.currentTimeMillis()/1000);

    }
}
